﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ignore="http://www.ignore.com"
    xmlns:bar="clr-namespace:BindableApplicationBar;assembly=BindableApplicationBar"
    xmlns:Toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
    x:Class="IkeCode.WP7.HQReader.Views.MainPage"
    mc:Ignorable="d ignore"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"
    Orientation="Portrait"
    d:DesignWidth="480"
    d:DesignHeight="696"
    shell:SystemTray.IsVisible="True"
    DataContext="{Binding Main, Source={StaticResource Locator}}">

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot"
		  Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel"
					Grid.Row="0"
					Margin="24,24,0,12">
            <TextBlock x:Name="ApplicationTitle"
					   Text="{Binding PagePrimaryTitle}"
					   Style="{StaticResource PhoneTextSmallStyle}" />
            <TextBlock x:Name="PageTitle"
                       TextWrapping="Wrap"
					   Text="{Binding PageTitle}"
					   Margin="-3,-8,0,0"
					   Style="{StaticResource PhoneTextTitle1Style}" />
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Toolkit:WrapPanel Orientation="Horizontal" Grid.Row="1" Margin="12,0,12,0" x:Name="ContentPanel">
            <ContentControl Content="{Binding LoadingViewModel}" HorizontalContentAlignment="Stretch" Width="{Binding ElementName=ContentPanel, Path=ActualWidth}" MaxHeight="80" ContentTemplate="{StaticResource LoadingTemplate}"/>
            <ListBox ItemsSource="{Binding ListFeedPublishers}">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Toolkit:WrapPanel Orientation="Horizontal" HorizontalAlignment="Left" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border Width="220" MinHeight="90" MaxHeight="150" Margin="4" Background="{StaticResource PhoneBackgroundBrush}">
                            <Grid HorizontalAlignment="Center">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Tap">
                                        <i:InvokeCommandAction Command="{Binding DefaultActionCommand}" CommandParameter="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <Toolkit:ContextMenuService.ContextMenu>
                                    <Toolkit:ContextMenu>
                                        <Toolkit:MenuItem Header="Pin" Command="{Binding Main.PinUnpinCommand, Source={StaticResource Locator}}" CommandParameter="{Binding}"/>
                                        <Toolkit:MenuItem Header="Edit" Command="{Binding Main.ManagerCommand, Source={StaticResource Locator}}" CommandParameter="{Binding}"/>
                                        <Toolkit:MenuItem Header="Remove" Command="{Binding Main.RemoveCommand, Source={StaticResource Locator}}" CommandParameter="{Binding}"/>
                                    </Toolkit:ContextMenu>
                                </Toolkit:ContextMenuService.ContextMenu>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <Border Grid.RowSpan="2" Background="{StaticResource PhoneBackgroundBrush}">
                                    <Image Source="{Binding ImageUrl}" Width="220" MinHeight="90" MaxHeight="150"/>
                                </Border>
                                <Border Opacity=".8" MinWidth="40" MinHeight="40" CornerRadius="50" Background="{StaticResource PhoneAccentBrush}" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="3">
                                    <TextBlock Text="{Binding NewestCount}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,2,0" Style="{StaticResource PhoneTextNormalStyle}"/>
                                </Border>
                                <Grid Grid.Row="1" MaxHeight="65" VerticalAlignment="Bottom">
                                    <StackPanel Background="{StaticResource PhoneAccentBrush}" VerticalAlignment="Stretch"/>
                                    <TextBlock Text="{Binding Title}" TextWrapping="Wrap" Margin="10,0,0,3" VerticalAlignment="Bottom" Style="{StaticResource PhoneTextSmallStyle}"/>
                                </Grid>
                            </Grid>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Toolkit:WrapPanel>
    </Grid>

    <bar:Bindable.ApplicationBar>
        <bar:BindableApplicationBar>
            <bar:BindableApplicationBarButton
            IconUri="/LocalResources/Images/appbar.add.rest.png"
            Text="Add"
            Command="{Binding ManagerCommand}" />
            <!--<bar:BindableApplicationBar.MenuItems>
                <bar:BindableApplicationBarMenuItem
                Text="Menu Item 1"
                Command="{Binding TestCommand}" />
            </bar:BindableApplicationBar.MenuItems>-->
        </bar:BindableApplicationBar>
    </bar:Bindable.ApplicationBar>
</phone:PhoneApplicationPage>